package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsGoodsAttributeMapper;
import com.qf.pojo.DtsGoodsAttribute;
import com.qf.service.DtsGoodsAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @version v1.0.0
 * @Description:
 * @author: 姜红凯
 * @date: 2022.02.23
 * @since 1.0
 */
@Service
public class DtsGoodsAttributeServiceImpl implements DtsGoodsAttributeService {

    @Autowired
    DtsGoodsAttributeMapper attributeMapper;

    @Override
    public List<DtsGoodsAttribute> findByGoodsId(Integer id) {
        LambdaQueryWrapper<DtsGoodsAttribute> wrapper = new LambdaQueryWrapper();
        wrapper.eq(DtsGoodsAttribute::getGoodsId,id) ;
        wrapper.eq(DtsGoodsAttribute::getDeleted,false);
        List<DtsGoodsAttribute> attributes = attributeMapper.selectList(wrapper);
        return attributes;
    }

    @Override
    public void deleteByGoodsId(Integer goodId) {
        LambdaQueryWrapper<DtsGoodsAttribute> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DtsGoodsAttribute::getGoodsId,goodId);
        attributeMapper.delete(wrapper);
    }

    @Override
    public void insert(DtsGoodsAttribute attribute) {
        attributeMapper.insert(attribute);
    }
}
